﻿/********************************************************************************
    Copyright (C) Binod Nepal, Planet Earth Solutions Pvt. Ltd., Kathmandu.
	Released under the terms of the GNU General Public License, GPL, 
	as published by the Free Software Foundation, either version 3 
	of the License, or (at your option) any later version.
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
    See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
***********************************************************************************/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;
using System.Web.Routing;

namespace MixNP.Web
{
    public class Global : System.Web.HttpApplication
    {

        protected static void RegisterRoutes(RouteCollection routes)
        {
            if (routes != null)
            {
                RouteTable.Routes.Add(new Route("{resource}.axd/{*pathInfo}", new StopRoutingHandler()));

                routes.MapPageRoute("DefaultRoute", "", "~/Classifieds/Index.aspx");
                routes.MapPageRoute("ContactUs", "contact-us.mix", "~/Classifieds/ContactUs.aspx");

                routes.MapPageRoute("UserView", "user/{salt}.mix", "~/Classifieds/UserView.aspx");

                routes.MapPageRoute("TermsOfUsePage", "legal/terms-of-use.mix", "~/Classifieds/Legal/TermsOfUse.aspx");
                routes.MapPageRoute("PrivacyPolicyPage", "legal/privacy-policy.mix", "~/Classifieds/Legal/PrivacyPolicy.aspx");

                routes.MapPageRoute("IndexPage", "index.mix", "~/Classifieds/Index.aspx");
                routes.MapPageRoute("Play", "play.mix", "~/Classifieds/Play.aspx");
                routes.MapPageRoute("Play2", "play/{item-id}.mix", "~/Classifieds/Play.aspx");

                routes.MapPageRoute("Dashboard", "dashboard.mix", "~/Classifieds/Dashboard.aspx");


                routes.MapPageRoute("ItemViewRoute", "view/{parent-category-alias}/{category-alias}/{item-id}/{alias}.mix", "~/Classifieds/ItemView.aspx");

                routes.MapPageRoute("ParentCategoryViewRoute", "view/{parent-alias}.mix", "~/Classifieds/CategoryView.aspx");
                routes.MapPageRoute("CategoryViewRoute", "view/{parent-alias}/{alias}.mix", "~/Classifieds/CategoryView.aspx");

                routes.MapPageRoute("SearchRoute", "search.mix", "~/Classifieds/Search.aspx");
                routes.MapPageRoute("SearchRoute2", "search/", "~/Classifieds/Search.aspx");

                routes.MapPageRoute("Profile", "account/profile.mix", "~/Classifieds/Account/Profile.aspx");
                routes.MapPageRoute("SellItem", "sell/{alias}.mix", "~/Classifieds/Sell.aspx");
                routes.MapPageRoute("EditItem", "sell/{alias}/{item-id}/{item-alias}.mix", "~/Classifieds/Sell.aspx");

                routes.MapPageRoute("MyAd", "my/ad.mix", "~/Classifieds/My/AddNewAd.aspx");
                routes.MapPageRoute("MyAds", "my/ads.mix", "~/Classifieds/My/ManageAds.aspx");
                routes.MapPageRoute("Wishlist", "my/wishlist.mix", "~/Classifieds/My/Wishlist.aspx");
                routes.MapPageRoute("Watchlist", "my/watchlist.mix", "~/Classifieds/My/Watchlist.aspx");
                routes.MapPageRoute("MyMessages", "my/messaging.mix", "~/Classifieds/My/Messages.aspx");
                routes.MapPageRoute("ViewedAds", "my/viewed-ads.mix", "~/Classifieds/My/ViewedAds.aspx");
                
                routes.MapPageRoute("ChangePassword", "change-password.mix", "~/Classifieds/ChangePassword.aspx");

                routes.MapPageRoute("WhyUploadImage", "why/upload-image-to-increase-visibility.mix", "~/Classifieds/Promotional/WhyUploadImage.aspx");

                routes.MapPageRoute("NotFound", "error/404/file-not-found.mix", "~/Classifieds/Static/404.aspx");
                routes.MapPageRoute("Offline", "offline.mix", "~/Classifieds/Static/Offline.aspx");
                routes.MapPageRoute("Error", "error/500/server-error.mix", "~/Classifieds/Static/GenericError.aspx");


                routes.MapPageRoute("CantAccessAccount", "cant-access-account.mix", "~/Classifieds/Account/CantAccessAccount.aspx");
                routes.MapPageRoute("Recover", "recover", "~/Classifieds/Account/Recover.aspx");
                routes.MapPageRoute("Recover2", "recover/{token}.mix", "~/Classifieds/Account/Recover.aspx");
                routes.MapPageRoute("SignIn", "sign-in.mix", "~/Classifieds/Account/SignIn.aspx");
                routes.MapPageRoute("SignOff", "signoff.mix", "~/Classifieds/Account/SignOff.aspx");

                routes.MapPageRoute("SignUpRoute", "sign-up.mix", "~/Classifieds/Account/SignUp.aspx");
                routes.MapPageRoute("ConfirmationEmailSent", "sign-up/confirm/email-sent.mix", "~/Classifieds/Account/Confirmation/ConfirmationEmailSent.aspx");
                routes.MapPageRoute("ResendConfirmationEmail", "sign-up/confirm/resend-email.mix", "~/Classifieds/Account/Confirmation/ResendConfirmationEmail.aspx");

                routes.MapPageRoute("ConfirmAccount", "confirm/{salt}.mix", "~/Classifieds/Account/Confirmation/ConfirmRegistration.aspx");
                routes.MapPageRoute("CancelAccount", "cancel/{salt}.mix", "~/Classifieds/Account/Confirmation/UnconfirmRegistration.aspx");
                routes.MapPageRoute("AccessIsDenied", "access-denied.mix", "~/Classifieds/AccessIsDenied.aspx");
            }
        }

        void Application_Start(object sender, EventArgs e)
        {
            RegisterRoutes(RouteTable.Routes);
        }

        void Application_End(object sender, EventArgs e)
        {
            //  Code that runs on application shutdown

        }

        void Application_Error(object sender, EventArgs e)
        {
            // Code that runs when an unhandled error occurs

        }

        void Session_Start(object sender, EventArgs e)
        {
            // Code that runs when a new session is started

        }

        void Session_End(object sender, EventArgs e)
        {
            // Code that runs when a session ends. 
            // Note: The Session_End event is raised only when the sessionstate mode
            // is set to InProc in the Web.config file. If session mode is set to StateServer 
            // or SQLServer, the event is not raised.

        }
    }
}
